In [3]:
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
file_path = "C:/Users/rucha/OneDrive/Desktop/Ruchi/restaurent dataset.csv"  
df = pd.read_csv(file_path)

#The aggregate rating column
print(df['Aggregate rating'].describe())

#Plot the ratings
plt.figure(figsize=(10, 6))
sns.histplot(df['Aggregate rating'], bins=20, kde=True, color='lightgreen')
plt.xlabel('Aggregate Rating')
plt.ylabel('Frequency')
plt.title('Distribution of Aggregate Ratings')
plt.grid(True)
plt.show()

#Most comman rating range
rating_counts = df['Aggregate rating'].value_counts().sort_index()

bins = [0, 1, 2, 3, 4, 5]
rating_ranges = pd.cut(df['Aggregate rating'], bins=bins, include_lowest=True)
range_counts = rating_ranges.value_counts().sort_index()
most_common_range = range_counts.idxmax()
most_common_count = range_counts.max()
print(f"The most common rating range is {most_common_range} with {most_common_count} occurrences.")
count    9551.000000
mean        2.666370
std         1.516378
min         0.000000
25%         2.500000
50%         3.200000
75%         3.700000
max         4.900000
Name: Aggregate rating, dtype: float64
The most common rating range is (3.0, 4.0] with 4388 occurrences.
In [2]:
import pandas as pd
file_path = "C:/Users/rucha/OneDrive/Desktop/Ruchi/restaurent dataset.csv" 
df = pd.read_csv(file_path)

print(df['Votes'].describe())

average_votes = df['Votes'].mean()
print(f"The average number of votes received by restaurants is {average_votes:.2f}.")
count     9551.000000
mean       156.909748
std        430.169145
min          0.000000
25%          5.000000
50%         31.000000
75%        131.000000
max      10934.000000
Name: Votes, dtype: float64
The average number of votes received by restaurants is 156.91.
In [4]:
import pandas as pd
from collections import Counter
from itertools import combinations
import matplotlib.pyplot as plt

file_path = "C:/Users/rucha/OneDrive/Desktop/Ruchi/restaurent dataset.csv"  
df = pd.read_csv(file_path)
print(df['Cuisines'].head())  

df = df.dropna(subset=['Cuisines'])
df['Cuisines'] = df['Cuisines'].astype(str).apply(lambda x: x.split(', '))

comb_counter = Counter()


for cuisines in df['Cuisines']:
  
    for i in range(1, len(cuisines) + 1):
        comb_counter.update(combinations(cuisines, i))


comb_counts_df = pd.DataFrame(comb_counter.items(), columns=['Combination', 'Count'])

comb_counts_df = comb_counts_df.sort_values(by='Count', ascending=False)
comb_counts_df = comb_counts_df[comb_counts_df['Combination'].apply(lambda x: len(x) > 1)]


print(comb_counts_df.head(10))


top_combinations = comb_counts_df.head(10)
top_combinations['Combination'] = top_combinations['Combination'].apply(lambda x: ', '.join(x))

plt.figure(figsize=(10, 6))
plt.barh(top_combinations['Combination'], top_combinations['Count'], color='lightgreen')
plt.xlabel('Count')
plt.ylabel('Cuisine Combination')
plt.title('Top 10 Most Common Cuisine Combinations')
plt.gca().invert_yaxis()
plt.show()
0          French, Japanese, Desserts
1                            Japanese
2    Seafood, Asian, Filipino, Indian
3                     Japanese, Sushi
4                    Japanese, Korean
Name: Cuisines, dtype: object
                       Combination  Count
759        (North Indian, Chinese)   1516
727        (North Indian, Mughlai)    728
874      (North Indian, Fast Food)    377
977           (Chinese, Fast Food)    331
794   (North Indian, South Indian)    314
834    (North Indian, Continental)    288
788        (Chinese, North Indian)    268
824             (Bakery, Desserts)    263
1200            (Mughlai, Chinese)    258
795        (South Indian, Chinese)    239
C:\Users\rucha\AppData\Local\Temp\ipykernel_8988\4026401783.py:32: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  top_combinations['Combination'] = top_combinations['Combination'].apply(lambda x: ', '.join(x))
In [7]:
import pandas as pd
from itertools import combinations
from collections import defaultdict
import matplotlib.pyplot as plt


file_path = "C:/Users/rucha/OneDrive/Desktop/Ruchi/restaurent dataset.csv"  
df = pd.read_csv(file_path)


print(df[['Cuisines', 'Aggregate rating']].head())  


df = df.dropna(subset=['Cuisines', 'Aggregate rating'])


df['Cuisines'] = df['Cuisines'].astype(str).apply(lambda x: x.split(', '))


ratings_dict = defaultdict(lambda: {'sum': 0, 'count': 0})

for index, row in df.iterrows():
    cuisines = row['Cuisines']
    rating = row['Aggregate rating']
    
 
    for i in range(1, len(cuisines) + 1):
        for combo in combinations(cuisines, i):
            ratings_dict[combo]['sum'] += rating
            ratings_dict[combo]['count'] += 1


avg_ratings = {combo: data['sum'] / data['count'] for combo, data in ratings_dict.items()}


avg_ratings_df = pd.DataFrame(avg_ratings.items(), columns=['Combination', 'Average Rating'])


avg_ratings_df = avg_ratings_df.sort_values(by='Average Rating', ascending=False)


print(avg_ratings_df.head(10))


top_avg_ratings = avg_ratings_df.head(10)
top_avg_ratings['Combination'] = top_avg_ratings['Combination'].apply(lambda x: ', '.join(x))

plt.figure(figsize=(10, 6))
plt.barh(top_avg_ratings['Combination'], top_avg_ratings['Average Rating'], color='lightgreen')
plt.xlabel('Average Rating')
plt.ylabel('Cuisine Combination')
plt.title('Top 10 Cuisine Combinations with Highest Average Ratings')
plt.gca().invert_yaxis()
plt.show()
                           Cuisines  Aggregate rating
0        French, Japanese, Desserts               4.8
1                          Japanese               4.5
2  Seafood, Asian, Filipino, Indian               4.4
3                   Japanese, Sushi               4.9
4                  Japanese, Korean               4.8
                            Combination  Average Rating
319          (BBQ, Breakfast, Southern)             4.9
240      (American, Caribbean, Seafood)             4.9
476           (Burger, Bar Food, Steak)             4.9
8062          (American, Burger, Grill)             4.9
459           (American, BBQ, Sandwich)             4.9
458           (American, Sandwich, Tea)             4.9
457                     (Sandwich, Tea)             4.9
2295            (Mexican, Healthy Food)             4.9
2296  (Mexican, American, Healthy Food)             4.9
38                   (European, Indian)             4.9
C:\Users\rucha\AppData\Local\Temp\ipykernel_8988\3271146721.py:46: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  top_avg_ratings['Combination'] = top_avg_ratings['Combination'].apply(lambda x: ', '.join(x))
In [5]:
import pandas as pd
import folium
file_path = "C:/Users/rucha/OneDrive/Desktop/Ruchi/restaurent dataset.csv"  
df = pd.read_csv(file_path)

print(df[['Latitude', 'Longitude']].head())  

df = df.dropna(subset=['Latitude', 'Longitude'])
map_center = [df['Latitude'].mean(), df['Longitude'].mean()]
mymap = folium.Map(location=map_center, zoom_start=12)
for idx, row in df.iterrows():
    folium.Marker([row['Latitude'], row['Longitude']], popup=row['Restaurant Name']).add_to(mymap)
mymap.save("restaurants_map.html")
mymap
    Latitude   Longitude
0  14.565443  121.027535
1  14.553708  121.014101
2  14.581404  121.056831
3  14.585318  121.056475
4  14.584450  121.057508
Out[5]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [8]:
import pandas as pd
from sklearn.cluster import KMeans
import folium
import matplotlib.pyplot as plt

file_path = "C:/Users/rucha/OneDrive/Desktop/Ruchi/restaurent dataset.csv"  
df = pd.read_csv(file_path)


print(df[['Latitude', 'Longitude']].head())  
df = df.dropna(subset=['Latitude', 'Longitude'])


coordinates = df[['Latitude', 'Longitude']]
kmeans = KMeans(n_clusters=5, random_state=42)  
kmeans.fit(coordinates)
df['Cluster'] = kmeans.labels_


map_center = [df['Latitude'].mean(), df['Longitude'].mean()]
mymap = folium.Map(location=map_center, zoom_start=12)
colors = ['yellow', 'lightgreen', 'green', 'darkgreen', 'black']

for idx, row in df.iterrows():
    folium.Marker([row['Latitude'], row['Longitude']],
                  popup=row['Restaurant Name'],
                  icon=folium.Icon(color=colors[row['Cluster']])).add_to(mymap)

mymap.save("restaurants_clusters_map.html")
mymap

plt.figure(figsize=(10, 6))
plt.scatter(df['Longitude'], df['Latitude'], c=df['Cluster'], cmap='viridis', marker='o')
plt.xlabel('Longitude')
plt.ylabel('Latitude')
plt.title('Restaurant Clusters')
plt.show()
    Latitude   Longitude
0  14.565443  121.027535
1  14.553708  121.014101
2  14.581404  121.056831
3  14.585318  121.056475
4  14.584450  121.057508
C:\Users\rucha\anaconda3\Lib\site-packages\sklearn\cluster\_kmeans.py:1412: FutureWarning: The default value of `n_init` will change from 10 to 'auto' in 1.4. Set the value of `n_init` explicitly to suppress the warning
  super()._check_params_vs_input(X, default_n_init=10)
C:\Users\rucha\AppData\Local\Temp\ipykernel_8988\1657638629.py:27: UserWarning: color argument of Icon should be one of: {'lightred', 'lightgray', 'darkpurple', 'darkgreen', 'lightblue', 'darkblue', 'gray', 'blue', 'beige', 'black', 'red', 'green', 'lightgreen', 'darkred', 'cadetblue', 'pink', 'orange', 'white', 'purple'}.
  icon=folium.Icon(color=colors[row['Cluster']])).add_to(mymap)
In [7]:
import pandas as pd

file_path = "C:/Users/rucha/OneDrive/Desktop/Ruchi/restaurent dataset.csv"   
df = pd.read_csv(file_path)
print(df[['Restaurant Name', 'Latitude', 'Longitude']].head())

restaurant_counts = df.groupby('Restaurant Name').size().reset_index(name='Count')
chains = restaurant_counts[restaurant_counts['Count'] > 1]
print(chains)


chain_locations = df[df['Restaurant Name'].isin(chains['Restaurant Name'])]
print(chain_locations.sort_values(by=['Restaurant Name', 'Latitude', 'Longitude']))

chain_locations.to_csv('identified_chains.csv', index=False)
          Restaurant Name   Latitude   Longitude
0        Le Petit Souffle  14.565443  121.027535
1        Izakaya Kikufuji  14.553708  121.014101
2  Heat - Edsa Shangri-La  14.581404  121.056831
3                    Ooma  14.585318  121.056475
4             Sambo Kojin  14.584450  121.057508
           Restaurant Name  Count
7        10 Downing Street      2
27      221 B Baker Street      3
44      34 Parkstreet Lane      2
45    34, Chowringhee Lane     12
59          4700BC Popcorn      2
...                    ...    ...
7382                 Zaika      4
7388     Zaika Kathi Rolls      2
7416                  Zizo      3
7423       Zooby's Kitchen      2
7431                  buno      2

[733 rows x 2 columns]
      Restaurant ID     Restaurant Name  Country Code       City  \
2333        1400121   10 Downing Street             1     Indore   
751         2600031   10 Downing Street             1     Bhopal   
8039           7983  221 B Baker Street             1      Noida   
8498           5239  221 B Baker Street             1      Noida   
8848         312186  221 B Baker Street             1      Noida   
...             ...                 ...           ...        ...   
3088         309073                Zizo             1  New Delhi   
5927       18144480     Zooby's Kitchen             1  New Delhi   
8975       18418250     Zooby's Kitchen             1      Noida   
1870       18264995                buno             1    Gurgaon   
1560       18432226                buno             1    Gurgaon   

                                                Address  \
2333  Second Floor, Malhar Mega Mall, AB Road, Schem...   
751   Third Floor, DB City Mall, Maharana Pratap Nag...   
8039  10, Brahmaputra Shoping Complex, Sector 29, Noida   
8498         21, Jalvayu Vihar Market, Sector 25, Noida   
8848                  PG 30, TOT Mall, Sector 62, Noida   
...                                                 ...   
3088              K-18 & 22, Connaught Place, New Delhi   
5927                      New Friends Colony, New Delhi   
8975  Shop 31, Amrapali Princely Estate, Sector 76, ...   
1870  108, Vijay Vihar, Silokhera Road, Near BPTP Pa...   
1560  2nd Floor, Near Lifestyle, MGF Metropolis Mall...   

                            Locality                        Locality Verbose  \
2333                     Vijay Nagar                     Vijay Nagar, Indore   
751   DB City, Maharana Pratap Nagar  DB City, Maharana Pratap Nagar, Bhopal   
8039    Brahmaputra Shopping Complex     Brahmaputra Shopping Complex, Noida   
8498                       Sector 25                        Sector 25, Noida   
8848                       Sector 62                        Sector 62, Noida   
...                              ...                                     ...   
3088                 Connaught Place              Connaught Place, New Delhi   
5927              New Friends Colony           New Friends Colony, New Delhi   
8975                       Sector 72                        Sector 72, Noida   
1870                       Sector 30                      Sector 30, Gurgaon   
1560    MGF Metropolis Mall, MG Road   MGF Metropolis Mall, MG Road, Gurgaon   

      Longitude   Latitude                                          Cuisines  \
2333  75.894377  22.744648                             North Indian, Chinese   
751   77.429989  23.232357                             North Indian, Chinese   
8039  77.332667  28.570356                                            Bakery   
8498  77.337946  28.584376                                            Bakery   
8848  77.371606  28.614281                                            Bakery   
...         ...        ...                                               ...   
3088  77.219903  28.635299  Lebanese, Mediterranean, Middle Eastern, Arabian   
5927  77.271844  28.565280                    North Indian, Mughlai, Chinese   
8975  77.381456  28.566360                    North Indian, Mughlai, Chinese   
1870  77.055340  28.459874     Healthy Food, Cafe, Desserts, Italian, Bakery   
1560  77.081674  28.478398         Cafe, American, Desserts, Italian, Bakery   

      ...            Currency Has Table booking Has Online delivery  \
2333  ...  Indian Rupees(Rs.)                No                  No   
751   ...  Indian Rupees(Rs.)                No                  No   
8039  ...  Indian Rupees(Rs.)                No                 Yes   
8498  ...  Indian Rupees(Rs.)                No                 Yes   
8848  ...  Indian Rupees(Rs.)                No                 Yes   
...   ...                 ...               ...                 ...   
3088  ...  Indian Rupees(Rs.)               Yes                 Yes   
5927  ...  Indian Rupees(Rs.)                No                  No   
8975  ...  Indian Rupees(Rs.)               Yes                  No   
1870  ...  Indian Rupees(Rs.)                No                 Yes   
1560  ...  Indian Rupees(Rs.)                No                 Yes   

     Is delivering now Switch to order menu Price range  Aggregate rating  \
2333                No                   No           4               4.0   
751                 No                   No           3               4.0   
8039                No                   No           1               3.5   
8498                No                   No           1               3.4   
8848                No                   No           1               3.2   
...                ...                  ...         ...               ...   
3088                No                   No           3               3.9   
5927                No                   No           2               2.8   
8975                No                   No           2               3.5   
1870                No                   No           2               3.8   
1560                No                   No           2               3.7   

      Rating color Rating text Votes  
2333         Green   Very Good   413  
751          Green   Very Good   257  
8039        Yellow        Good    94  
8498        Orange     Average   102  
8848        Orange     Average    19  
...            ...         ...   ...  
3088        Yellow        Good  1071  
5927        Orange     Average    21  
8975        Yellow        Good    31  
1870        Yellow        Good    99  
1560        Yellow        Good    18  

[2839 rows x 21 columns]
In [9]:
import pandas as pd
import matplotlib.pyplot as plt
file_path = "C:/Users/rucha/OneDrive/Desktop/Ruchi/restaurent dataset.csv"  
df = pd.read_csv(file_path)


restaurant_counts = df.groupby('Restaurant Name').size().reset_index(name='Count')
chains = restaurant_counts[restaurant_counts['Count'] > 1]
chain_locations = df[df['Restaurant Name'].isin(chains['Restaurant Name'])]
print(chain_locations.sort_values(by=['Restaurant Name', 'Latitude', 'Longitude']))


chain_stats = chain_locations.groupby('Restaurant Name').agg({
    'Aggregate rating': 'mean',
    'Votes': 'sum'
}).reset_index()
chain_stats.columns = ['Restaurant Name', 'Average Rating', 'Total Votes']
print(chain_stats.sort_values(by='Average Rating', ascending=False))


chain_stats_sorted_by_votes = chain_stats.sort_values(by='Total Votes', ascending=False)

top_10_chains_by_rating = chain_stats.sort_values(by='Average Rating', ascending=False).head(10)
plt.figure(figsize=(12, 6))
plt.barh(top_10_chains_by_rating['Restaurant Name'], top_10_chains_by_rating['Average Rating'], color='lightgreen')
plt.xlabel('Average Rating')
plt.ylabel('Restaurant Chain')
plt.title('Top 10 Restaurant Chains by Average Rating')
plt.gca().invert_yaxis()
plt.show()


top_10_chains_by_votes = chain_stats_sorted_by_votes.head(10)
plt.figure(figsize=(12, 6))
plt.barh(top_10_chains_by_votes['Restaurant Name'], top_10_chains_by_votes['Total Votes'], color='darkgreen')
plt.xlabel('Total Votes')
plt.ylabel('Restaurant Chain')
plt.title('Top 10 Restaurant Chains by Total Votes')
plt.gca().invert_yaxis()
plt.show()
      Restaurant ID     Restaurant Name  Country Code       City  \
2333        1400121   10 Downing Street             1     Indore   
751         2600031   10 Downing Street             1     Bhopal   
8039           7983  221 B Baker Street             1      Noida   
8498           5239  221 B Baker Street             1      Noida   
8848         312186  221 B Baker Street             1      Noida   
...             ...                 ...           ...        ...   
3088         309073                Zizo             1  New Delhi   
5927       18144480     Zooby's Kitchen             1  New Delhi   
8975       18418250     Zooby's Kitchen             1      Noida   
1870       18264995                buno             1    Gurgaon   
1560       18432226                buno             1    Gurgaon   

                                                Address  \
2333  Second Floor, Malhar Mega Mall, AB Road, Schem...   
751   Third Floor, DB City Mall, Maharana Pratap Nag...   
8039  10, Brahmaputra Shoping Complex, Sector 29, Noida   
8498         21, Jalvayu Vihar Market, Sector 25, Noida   
8848                  PG 30, TOT Mall, Sector 62, Noida   
...                                                 ...   
3088              K-18 & 22, Connaught Place, New Delhi   
5927                      New Friends Colony, New Delhi   
8975  Shop 31, Amrapali Princely Estate, Sector 76, ...   
1870  108, Vijay Vihar, Silokhera Road, Near BPTP Pa...   
1560  2nd Floor, Near Lifestyle, MGF Metropolis Mall...   

                            Locality                        Locality Verbose  \
2333                     Vijay Nagar                     Vijay Nagar, Indore   
751   DB City, Maharana Pratap Nagar  DB City, Maharana Pratap Nagar, Bhopal   
8039    Brahmaputra Shopping Complex     Brahmaputra Shopping Complex, Noida   
8498                       Sector 25                        Sector 25, Noida   
8848                       Sector 62                        Sector 62, Noida   
...                              ...                                     ...   
3088                 Connaught Place              Connaught Place, New Delhi   
5927              New Friends Colony           New Friends Colony, New Delhi   
8975                       Sector 72                        Sector 72, Noida   
1870                       Sector 30                      Sector 30, Gurgaon   
1560    MGF Metropolis Mall, MG Road   MGF Metropolis Mall, MG Road, Gurgaon   

      Longitude   Latitude                                          Cuisines  \
2333  75.894377  22.744648                             North Indian, Chinese   
751   77.429989  23.232357                             North Indian, Chinese   
8039  77.332667  28.570356                                            Bakery   
8498  77.337946  28.584376                                            Bakery   
8848  77.371606  28.614281                                            Bakery   
...         ...        ...                                               ...   
3088  77.219903  28.635299  Lebanese, Mediterranean, Middle Eastern, Arabian   
5927  77.271844  28.565280                    North Indian, Mughlai, Chinese   
8975  77.381456  28.566360                    North Indian, Mughlai, Chinese   
1870  77.055340  28.459874     Healthy Food, Cafe, Desserts, Italian, Bakery   
1560  77.081674  28.478398         Cafe, American, Desserts, Italian, Bakery   

      ...            Currency Has Table booking Has Online delivery  \
2333  ...  Indian Rupees(Rs.)                No                  No   
751   ...  Indian Rupees(Rs.)                No                  No   
8039  ...  Indian Rupees(Rs.)                No                 Yes   
8498  ...  Indian Rupees(Rs.)                No                 Yes   
8848  ...  Indian Rupees(Rs.)                No                 Yes   
...   ...                 ...               ...                 ...   
3088  ...  Indian Rupees(Rs.)               Yes                 Yes   
5927  ...  Indian Rupees(Rs.)                No                  No   
8975  ...  Indian Rupees(Rs.)               Yes                  No   
1870  ...  Indian Rupees(Rs.)                No                 Yes   
1560  ...  Indian Rupees(Rs.)                No                 Yes   

     Is delivering now Switch to order menu Price range  Aggregate rating  \
2333                No                   No           4               4.0   
751                 No                   No           3               4.0   
8039                No                   No           1               3.5   
8498                No                   No           1               3.4   
8848                No                   No           1               3.2   
...                ...                  ...         ...               ...   
3088                No                   No           3               3.9   
5927                No                   No           2               2.8   
8975                No                   No           2               3.5   
1870                No                   No           2               3.8   
1560                No                   No           2               3.7   

      Rating color Rating text Votes  
2333         Green   Very Good   413  
751          Green   Very Good   257  
8039        Yellow        Good    94  
8498        Orange     Average   102  
8848        Orange     Average    19  
...            ...         ...   ...  
3088        Yellow        Good  1071  
5927        Orange     Average    21  
8975        Yellow        Good    31  
1870        Yellow        Good    99  
1560        Yellow        Good    18  

[2839 rows x 21 columns]
                     Restaurant Name  Average Rating  Total Votes
628                 Talaga Sampireun           4.900         5514
588                 Silantro Fil-Mex           4.850         1364
8            AB's Absolute Barbecues           4.850         3151
7          AB's - Absolute Barbecues           4.825        13400
448               Naturals Ice Cream           4.800         3094
..                               ...             ...          ...
78                       Big Biryani           0.000            1
248                 Flavours Kitchen           0.000            3
34                      Anand Sweets           0.000            3
533  Radha Swami Shudh Vaishno Dhaba           0.000            6
469       OCD - Online Cake Delivery           0.000            2

[733 rows x 3 columns]
In [ ]: